#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1000;
int main(){
	int a,b,d;
	scanf("%d%d%d",&a,&b,&d);
	int m=a+b,n=0;
	if(m){
			int num[maxn];
			while(m){
				num[n]=m%d;
				m/=d;
				n++;
			}
			for(int i=n-1;i>=0;i--){
				printf("%d",num[i]);
			} 
			printf("\n");
	}
	else printf("0\n");
	return 0;
}
